# coding: utf-8
'''
Description: 
version: 1.0.0
Author: peng2.zhang
Date: 2021-09-01 18:19:35
LastEditors: peng2.zhang
LastEditTime: 2022-05-30 19:01:58
'''

class BASE_TYPE(object):                                                                                               
    """                                                                                                                
        定义BASE_TYPE                                                                                                  
        通过get_id_by_name和get_name_by_id进行双向查询                                                                 
    """                                                                                                                

    @classmethod
    def get_attrs(cls):
        attrs = [i for i in dir(cls) if hasattr(getattr(cls, i), "category")]
        return attrs

    @classmethod                                                                                                       
    def to_dict(cls):                                                                                                  
        items = cls.get_attrs()
        d = {}                                                                                                         
        for i in items:                                                                                                
            d[getattr(getattr(cls, i), "ID")] = getattr(getattr(cls, i), "NAME")                                       
        return d                                                                                                       
                                                                                                                       
    @classmethod                                                                                                       
    def to_list(cls):                                                                                                  
        items = cls.get_attrs()
        li = []
        for i in items:
            d = dict(ID=getattr(getattr(cls, i), "ID"), NAME=getattr(getattr(cls, i), "NAME"))
            li.append(d)
        li = sorted(li, key=lambda li: li["ID"])
        return li

    @classmethod                                                                                                       
    def get_id_by_name(cls, name):                                                                                     
        items = cls.get_attrs()
        d = {}                                                                                                         
        for i in items:                                                                                                
            d[getattr(getattr(cls, i), "NAME")] = getattr(getattr(cls, i), "ID")                                       
        id = d.get(name)                                                                                               
        return id

    @classmethod
    def get_name_by_id(cls, id):
        items = cls.get_attrs()
        d = {}
        for i in items:
            d[getattr(getattr(cls, i), "ID")] = getattr(getattr(cls, i), "NAME")
        name = d.get(id)
        return name

    @classmethod
    def get_attr_by_id(cls, id):
        items = cls.get_attrs()
        d = {}
        for i in items:
            d[getattr(getattr(cls, i), "ID")] = i
        attr_name = d.get(id)
        return attr_name


class Category:
    """
        定义Category
        用于定义ID、NAME的对应关系
    """
    category = True
    def __init__(self, ID, NAME):
        self.ID = ID
        self.NAME = NAME
    
    def __str__(self):
        return "<%s name:%s>" % (self.ID, self.NAME)

    def __unicode__(self):
        return u"%s-%s" % (self.ID, self.NAME)


class UserPassword(Category):
    def __init__(self, ID, NAME, PASS):
        self.ID = ID
        self.NAME = NAME
        self.PASS = PASS

class CODE:
    PASS = Category(0, "PASS")
    FAIL = Category(-1, "FAIL")


class EUREKA:
    STDCI = Category(0, "http://ad-eureka-stdci-ci.ecarx.com.cn/eureka/apps")
    ADMAPCI = Category(1, "http://ad-eureka-admapci-ci.ecarxmap.com/eureka/apps")
    ADDIPCI = Category(1, "https://dmp-eureka-ci.ecarxgroup.com/eureka/apps")


class JenkinsServer:
    DEFAULT = Category(0, "https://ad-ci.ecarxgroup.com")

class JenkinsUser:
    DEFAULT = UserPassword(0, "cGVuZzIuemhhbmc=", "cGVuZzAzNTFAYmo=")


class LanguageType(BASE_TYPE):
    JAVA = Category(1, "java")
    PYTHON = Category(2, "python")
    CXX = Category(3, "cxx")


class NacosCategory(Category):
    batch_id = 9
    def __init__(self, ID, NAME, nacos_data_ids=[], dev_data_ids=[], test_data_ids=[]):
        self.ID = ID
        self.NAME = NAME
        self.nacos_data_ids = nacos_data_ids
        self.dev_data_ids = dev_data_ids
        self.test_data_ids = test_data_ids

    @classmethod
    def set_batch_id(cls, batch_id=1):
        cls.batch_id = batch_id
        return cls


class ADMAPCI_JOBS(BASE_TYPE):
    admapci_ad_pc_det_app_meta = NacosCategory("admapci_ad-pc-det-app-meta", "动态物检测算法")
    admapci_ad_img_det_app_meta = NacosCategory("admapci_ad-img-det-app-meta", "图像检测算法")
    admapci_ad_img_seg_services_app_meta = NacosCategory("admapci_ad-img-seg-services-app-meta", "图像分割算法")
    admapci_ad_pc_seg_app_meta = NacosCategory("admapci_ad-pc-seg-app-meta", "拼接点云识别算法")
    #admapci_ad_ground_concate_app_meta = NacosCategory("admapci_ad-ground-concate-app-meta", "地面要素测距拼接算法")
    admapci_ad_signage_app_meta = NacosCategory("admapci_ad-signage-app-meta", "空中要素拼接")

    admapci_ad_daa_dynamic_removal_app_meta = NacosCategory("admapci_ad-daa-dynamic-removal-app-meta", "动态物检测服务", ["daa-dynamic-removal-service.yaml:DEFAULT_GROUP"], ["daa-dynamic-removal-service.yaml:DEFAULT_GROUP"], ["daa-dynamic-removal-service.yaml:DEFAULT_GROUP"])
    admapci_ad_daa_detection_service_app_meta = NacosCategory("admapci_ad-daa-detection-service-app-meta", "图像检测服务", ["daa-detection-service.yaml:DEFAULT_GROUP"], ["daa-detection-service.yaml:DEFAULT_GROUP"], ["daa-detection-service.yaml:DEFAULT_GROUP"])
    admapci_ad_daa_segment_service_app_meta = NacosCategory("admapci_ad-daa-segment-service-app-meta", "图像分割服务", ["daa-segment-service.yaml:DEFAULT_GROUP"], ["daa-segment-service.yaml:DEFAULT_GROUP"], ["daa-segment-service.yaml:DEFAULT_GROUP"])
    admapci_daa_upground_service_app_meta = NacosCategory("admapci_daa-upground-service-app-meta", "空中要素测距拼接服务", ["daa-upground-service.yaml:DEFAULT_GROUP"], ["daa-upground-service.yaml:DEFAULT_GROUP"], ["daa-upground-service.yaml:DEFAULT_GROUP"])
    admapci_daa_automultiple_service_app_meta = NacosCategory("admapci_daa-automultiple-service-app-meta", "拼接点云识别服务", ["daa-automultiple-service.yaml:DEFAULT_GROUP", "daa-automultiple-param.yaml:DEFAULT_GROUP"], ["daa-automultiple-service.yaml:DEFAULT_GROUP", "daa-automultiple-param.yaml:DEFAULT_GROUP"], ["daa-automultiple-service.yaml:DEFAULT_GROUP", "daa-automultiple-param.yaml:DEFAULT_GROUP"])
    admapci_daa_ground_service_app_meta = NacosCategory("admapci_daa-ground-service-app-meta", "地面要素测距拼接服务", ["daa_ground_service.properties:DEFAULT_GROUP"], ["daa_ground_service-dev.properties:DEFAULT_GROUP"], ["daa_ground_service-test.properties:DEFAULT_GROUP"])

    admapci_ad_imp_upload_web_app_meta = NacosCategory("admapci_ad-imp-upload-web-app-meta", "资料上传前端服务")
    admapci_ad_imp_upload_service_app_meta = NacosCategory("admapci_ad-imp-upload-service-app-meta", "资料上传后端服务", ["upload-service.properties:DEFAULT_GROUP"], ["upload-service-dev.properties:DEFAULT_GROUP"], ["upload-service-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_check_material_app_meta = NacosCategory("admapci_ad-imp-check-material-app-meta", "资料本地检查服务", ["imp-check-services-material.yml:DEFAULT_GROUP"], ["imp-check-services-material-dev.yml:DEFAULT_GROUP"], ["imp-check-services-material-test.yml:DEFAULT_GROUP"])
    admapci_ad_imp_check_workflow_app_meta = NacosCategory("admapci_ad-imp-check-workflow-app-meta", "资料云端检查服务", ["imp-check-services-workflow.yml:DEFAULT_GROUP"], ["imp-check-services-workflow-dev.yml:DEFAULT_GROUP"], ["imp-check-services-workflow-test.yml:DEFAULT_GROUP"])
    admapci_ad_imp_check_addata_app_meta = NacosCategory("admapci_ad-imp-check-addata-app-meta", "数据质检服务", ["imp-check-services.yml:DEFAULT_GROUP"], ["imp-check-services-dev.yml:DEFAULT_GROUP"], ["imp-check-services-test.yml:DEFAULT_GROUP"])
    admapci_ad_imp_check_platform_app_meta = NacosCategory("admapci_ad-imp-check-platform-app-meta", "检查平台服务", ["imp-check-platform.yml:DEFAULT_GROUP"], ["imp-check-platform-dev.yml:DEFAULT_GROUP"], ["imp-check-platform-test.yml:DEFAULT_GROUP"])
    admapci_ad_daa_standardization_app_meta = NacosCategory("admapci_ad-daa-standardization-app-meta", "资料归一化服务", ["daa-standardization-service.yaml:DEFAULT_GROUP", "daa-standardization-service-version.yaml:DEFAULT_GROUP"], ["daa-standardization-service.yaml:DEFAULT_GROUP", "daa-standardization-service-version.yaml:DEFAULT_GROUP"], ["daa-standardization-service.yaml:DEFAULT_GROUP", "daa-standardization-service-version.yaml:DEFAULT_GROUP"])
    admapci_ad_daa_single_slam_app_meta = NacosCategory("admapci_ad-daa-single-slam-app-meta", "单工程回环优化服务", ["daa-single-slam-service.yaml:DEFAULT_GROUP", "daa-single-slam-param.yaml:DEFAULT_GROUP"], ["daa-single-slam-service.yaml:DEFAULT_GROUP", "daa-single-slam-param.yaml:DEFAULT_GROUP"], ["daa-single-slam-service.yaml:DEFAULT_GROUP", "daa-single-slam-param.yaml:DEFAULT_GROUP"])
    admapci_ad_daa_road_section_app_meta = NacosCategory("admapci_ad-daa-road-section-app-meta", "roadsection切分服务", ["daa_roadsection_service.yaml:DEFAULT_GROUP"], ["daa_roadsection_service.yaml:DEFAULT_GROUP"], ["daa_roadsection_service.yaml:DEFAULT_GROUP"])
    admapci_ad_daa_multi_slam_app_meta = NacosCategory("admapci_ad-daa-multi-slam-app-meta", "轨迹对齐服务", ["daa-multi-slam-service.yaml:DEFAULT_GROUP", "daa-multi-slam-param.yaml:DEFAULT_GROUP"], ["daa-multi-slam-service.yaml:DEFAULT_GROUP", "daa-multi-slam-param.yaml:DEFAULT_GROUP"], ["daa-multi-slam-service.yaml:DEFAULT_GROUP", "daa-multi-slam-param.yaml:DEFAULT_GROUP"])
    admapci_ad_daa_multislam_optimization_app_meta = NacosCategory("admapci_ad-daa-multislam-optimization-app-meta", "slam多工程特征库处理服务", ["daa-multislam-optimization-service.yaml:DEFAULT_GROUP"], ["daa-multislam-optimization-service.yaml:DEFAULT_GROUP"], ["daa-multislam-optimization-service.yaml:DEFAULT_GROUP"])
    admapci_daa_pcpro_service_app_meta = NacosCategory("admapci_daa-pcpro-service-app-meta", "点云拼接服务", ["daa-pcpro-service.yaml:DEFAULT_GROUP", "daa-pcpro-service-algorithm.yaml:DEFAULT_GROUP"], ["daa-pcpro-service.yaml:DEFAULT_GROUP", "daa-pcpro-service-algorithm.yaml:DEFAULT_GROUP"], ["daa-pcpro-service.yaml:DEFAULT_GROUP", "daa-pcpro-service-algorithm.yaml:DEFAULT_GROUP"])
    admapci_ad_daa_slam_artificial_service_app_meta = NacosCategory("admapci_ad-daa-slam-artificial-service-app-meta", "半自动轨迹对齐后端服务", ["slam-artifical-service.properties:DEFAULT_GROUP"], ["slam-artifical-service-dev.properties:DEFAULT_GROUP"], ["slam-artifical-service-test.properties:DEFAULT_GROUP"])
    admapci_ad_slam_artificial_web_app_meta = NacosCategory("admapci_ad-slam-artificial-web-app-meta", "半自动轨迹对齐前端服务")
    admapci_ad_slam_alignment_app_meta = NacosCategory("admapci_ad-slam-alignment-app-meta", "半自动对齐算法服务")
    admapci_ad_imp_tasksplit_interface_app_meta = NacosCategory("admapci_ad-imp-tasksplit-interface-app-meta", "任务切分", ["imp-tasksplit-interface.properties:DEFAULT_GROUP"], ["imp-tasksplit-interface-dev.properties:DEFAULT_GROUP"])
    admapci_ad_imp_matchdiff_app_meta = NacosCategory("admapci_ad-imp-matchdiff-app-meta", "几何构建", ["env_config.py:MATCH_DIFF","process_config.py:MATCH_DIFF"], ["env_config.py:MATCH_DIFF","process_config.py:MATCH_DIFF"], ["env_config.py:MATCH_DIFF","process_config.py:MATCH_DIFF"])
    admapci_ad_editor_web_app_meta = NacosCategory("admapci_ad-editor-web-app-meta", "编辑平台（前端）")
    admapci_ad_imp_edit_services_app_meta = NacosCategory("admapci_ad-imp-edit-services-app-meta", "编辑平台（后端）", ["imp-edit-services.properties:DEFAULT_GROUP"], ["imp-edit-services-dev.properties:DEFAULT_GROUP"], ["imp-edit-services-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_build_service_app_meta = NacosCategory("admapci_ad-imp-build-service-app-meta", "自动构建", ["imp-build-service.properties:DEFAULT_GROUP"], ["imp-build-service-dev.properties:DEFAULT_GROUP"], ["imp-build-service-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_prepare_interface_recognition_app_meta = NacosCategory("admapci_ad-imp-prepare-interface-recognition-app-meta", "人工识别前资料准备", ["imp-prepare-interface-recognition.properties:DEFAULT_GROUP"], ["imp-prepare-interface-recognition.properties:DEFAULT_GROUP"], ["imp-prepare-interface-recognition.properties:DEFAULT_GROUP"])
    admapci_ad_imp_prepare_interface_manbuild_app_meta = NacosCategory("admapci_ad-imp-prepare-interface-manbuild-app-meta", "人工构建前资料准备", ["imp-prepare-interface-manbuild.properties:DEFAULT_GROUP"], ["imp-prepare-interface-manbuild.properties:DEFAULT_GROUP"], ["imp-prepare-interface-manbuild.properties:DEFAULT_GROUP"])
    admapci_ad_imp_postprocess_service_app_meta = NacosCategory("admapci_ad-imp-postprocess-service-app-meta", "制图后处理", ["imp-postprocess-service.properties:DEFAULT_GROUP"], ["imp-postprocess-service-dev.properties:DEFAULT_GROUP"], ["imp-postprocess-service-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_autolink_app_meta = NacosCategory("admapci_ad-imp-autolink-app-meta", "自动接边", ["imp-autolink-service.properties:DEFAULT_GROUP"], ["imp-autolink-service-dev.properties:DEFAULT_GROUP"], ["imp-autolink-service-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_mergeinto_service_app_meta = NacosCategory("admapci_ad-imp-mergeinto-service-app-meta", "融合入库", ["mergeinto.properties:DEFAULT_GROUP"], ["mergeinto-dev.properties:DEFAULT_GROUP"], ["mergeinto-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_process_store_app_meta = NacosCategory("admapci_ad-imp-process-store-app-meta", "过程库", ["imp-process-store.properties:DEFAULT_GROUP"], ["imp-process-store-dev.properties:DEFAULT_GROUP"], ["imp-process-store-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_querydb_new_app_meta = NacosCategory("admapci_ad-imp-querydb-new-app-meta", "母库查询", ["imp-querydb-new-admapci-ci.json:DEFAULT_GROUP"], ["imp-querydb-new-dev.json:DEFAULT_GROUP"], ["imp-querydb-new-test.json:DEFAULT_GROUP"])
    admapci_ad_imp_mbuild_server_app_meta = NacosCategory("admapci_ad-imp-mbuild-server-app-meta", "交互式构建", ["imp-mbuild-server.properties:DEFAULT_GROUP"], ["imp-mbuild-server-dev.properties:DEFAULT_GROUP"], ["imp-mbuild-server-test.properties:DEFAULT_GROUP"])
    admapci_ad_imp_task_web_app_meta = NacosCategory("admapci_ad-imp-task-web-app-meta", "工作流（前端）")
    admapci_ad_imp_task_service_app_meta = NacosCategory("admapci_ad-imp-task-service-app-meta", "工作流（后端）", ["imp-task-service.properties:DEFAULT_GROUP"], ["imp-task-service-dev.properties:DEFAULT_GROUP"], ["imp-task-service-test.properties:DEFAULT_GROUP"])
    # admapci_admapci-imp-register = NacosCategory("admapci_admapci-imp-register", "注册中心服务")
    # admapci_admapci-imp-message = NacosCategory("admapci_admapci-imp-message", "消息通知服务")
    # admapci_admapci-imp-user = NacosCategory("admapci_admapci-imp-user", "用户中心服务")
    # admapci_admapci-imp-gateway = NacosCategory("admapci_admapci-imp-gateway", "网关服务")
    # admapci_admapci-imp-config = NacosCategory("admapci_admapci-imp-config", "配置中心")
    admapci_ad_imp_daa_extract_service_app_meta = NacosCategory("admapci_ad-imp-daa-extract-service-app-meta", "抽帧服务", ["daa-extract-service.yaml:DEFAULT_GROUP"], ["daa-extract-service.yaml:DEFAULT_GROUP"], ["daa-extract-service.yaml:DEFAULT_GROUP"])
    # admapci_ad_imp_public_service_app_meta = NacosCategory("admapci_ad-imp-public-service-app-meta", "ID服务")
    # admapci_ad_imp_postprocess_service_app_meta = NacosCategory("admapci_ad-imp-postprocess-service-app-meta", "IE解算")
    # admapci_ad_daa_basicdata_query_service_app_meta = NacosCategory("admapci_ad-daa-basicdata-query-service-app-meta", "资料公共服务-查询服务")
    admapci_ad_compare_diff_app_meta = NacosCategory("admapci_ad-compare-diff-app-meta", "差分对比", ["imp-compare-diff-admapci-ci.json:DEFAULT_GROUP"], ["imp-compare-diff-dev.json:DEFAULT_GROUP"], ["imp-compare-diff-test.json:DEFAULT_GROUP"])
    admapci_ad_imp_problemdb_app_meta = NacosCategory("admapci_ad-imp-problemdb-app-meta", "问题库", ["imp-problemdb-service.properties:DEFAULT_GROUP"], ["imp-problemdb-service-dev.properties:DEFAULT_GROUP"], ["imp-problemdb-service-test.properties:DEFAULT_GROUP"])
    # admapci_ad_imp_data_transform_app_meta = NacosCategory("admapci_ad-imp-data-transform-app-meta", "规格转换")
    admapci_ad_imp_vec_mapping_app_meta = NacosCategory("admapci_ad-imp-vec-mapping-app-meta", "矢量建图", ["imp-vec-mapping-admapci-ci.json:DEFAULT_GROUP"], ["imp-vec-mapping-dev.json:DEFAULT_GROUP"], ["imp-vec-mapping-test.json:DEFAULT_GROUP"])
    admapci_imp_compile_tasksplit_app_meta = NacosCategory("admapci_imp-compile-tasksplit-app-meta", "编译预切分服务", ["imp-compile-tasksplit-service.properties:DEFAULT_GROUP"], ["imp-compile-tasksplit-service-dev.properties:DEFAULT_GROUP"], ["imp-compile-tasksplit-service-test.properties:DEFAULT_GROUP"])
    admapci_imp_std_mergeinto_service_app_meta = NacosCategory("admapci_imp-std-mergeinto-service-app-meta", "std数据入库服务", ["imp-std-mergeinto-service.properties:DEFAULT_GROUP"], ["imp-std-mergeinto-service-dev.properties:DEFAULT_GROUP"], ["imp-std-mergeinto-service-test.properties:DEFAULT_GROUP"])
    admapci_data_compile_service_app_meta = NacosCategory("admapci_data-compile-service-app-meta", "编译", ["data-compile-service.yaml:DEFAULT_GROUP"], ["data-compile-service.yaml:DEFAULT_GROUP"], ["data-compile-service.yaml:DEFAULT_GROUP"])
    admapci_imp_precompild_app_meta = NacosCategory("admapci_imp-precompild-app-meta", "编译预处理", ["env_config.py:imp-precompile-service","process_config.py:imp-precompile-service"], ["env_config.py:imp-precompile-service","process_config.py:imp-precompile-service"], ["env_config.py:imp-precompile-service","process_config.py:imp-precompile-service"])

# admapci_ad-daa-segment-service-app-meta --> admapci_ad-img-seg-services-app-meta
# admapci_ad-daa-dynamic-removal-app-meta --> admapci_ad-pc-det-app-meta
# admapci_ad-daa-detection-service-app-meta --> admapci_ad-img-det-app-meta
# 地面
# admapci_daa-ground-service-app-meta --> admapci_ad-ground-concate-app-meta
# 空中
# admapci_daa-upground-concate-app-meta --> admapci_ad-signage-app-meta
# 拼接点云识别
# admapci_daa-automultiple-service-app-meta -->admapci_ad-pc-seg-app-meta



class ADDIPCI_JOBS(BASE_TYPE):
    #addipci_dmp_upload_service_app_meta = NacosCategory("addipci_dmp-upload-service-app-meta", "上传服务", ["dmp-upload-service.properties:DEFAULT_GROUP"])
    #addipci_dmp_check_service_app_meta = NacosCategory("addipci_dmp-check-service-app-meta", "资料检查服务", ["imp-check-services-material.yml:DEFAULT_GROUP"])
    addipci_dmp_scenario_app_meta = NacosCategory("addipci_dmp-scenario-app-meta", "场景服务", ["dmp-scenario-service.yaml:DEFAULT_GROUP"])
    addipci_dmp_simualtion_app_meta = NacosCategory("addipci_dmp-simualtion-app-meta", "场景服务", ["dmp-simulation-service.yaml:DEFAULT_GROUP"])
